﻿using Microsoft.EntityFrameworkCore;
using Prism.Ioc;
using Prism.Regions;
using Prism.Unity;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Windows;
using WpfApp_SmartParking.Base;
using WpfApp_SmartParking.Views;
using WpfApp_SmartParking.Views.Dialog;
using WpfApp_SmartParking.Views.Pages;
using WpfApp_SmartParking_IService;
using WpfApp_SmartParking_Orm;
using WpfApp_SmartParking_Service;

namespace WpfApp_SmartParking
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : PrismApplication
    {
        protected override Window CreateShell()
        {
            return Container.Resolve<MainView>();
        }

        protected override void OnStartup(StartupEventArgs e)
        {
            if (e.Args.Length > 0) 
            {
                string args = e.Args[0];
                if (args == "restart") 
                {
                    
                }
            }
            base.OnStartup(e);
        }

        protected override void InitializeShell(Window shell)
        {
            base.InitializeShell(shell);

            Container.Resolve<IRegionManager>().RegisterViewWithRegion("MainTabRegion", "DashboardView");
        }

        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            containerRegistry.RegisterDialog<LoginView>();
            containerRegistry.RegisterDialog<MenuDetailView>();
            containerRegistry.RegisterDialog<UserDetailView>();
            containerRegistry.RegisterDialogWindow<DialogWindowEx>();

            containerRegistry.Register<DbContext, EFDbContext>();
            containerRegistry.Register<IUserService, UserService>();
            containerRegistry.Register<IMenuService, MenuService>();

            containerRegistry.RegisterForNavigation<DashboardView>();
            containerRegistry.RegisterForNavigation<MenuManagementView>();
            containerRegistry.RegisterForNavigation<UserManagementView>();

        }
    }

}
